{{indexmenu_n>1}}
====== Prerequisites ======


The following assumes you are able to build OpenCPN from source and have the needed tools. You can find the detailed instructions at [[opencpn:developer_manual:developer_guide:compiling_linux|Compiling Linux]] and [[opencpn:developer_manual:developer_guide:compiling_windows|Compiling Windows]]

===== Git magic =====

If you followed the building instructions above, you already have the local repository clone and all the needed tools on your computer. Open a terminal (run cmd.exe) and change to the directory where you have cloned the source.\\
//Personal advice: to save a lot of problems later, don't be afraid to use a lot of small per-task branches. Could sound weird especially to the guys used to the traditional version control systems, but this is how it's meant to be with git and modern distributed version control systems. And believe me that merging branches is much easier than cherry-picking commits belonging to a single task.// \\
Following are a few git commands you will for sure need sooner or later:\\
\\
To update to the latest upstream code

<code>
git pull origin
</code>

To see all the branches in your local repository

<code>
git branch
</code>

To create a new branch

<code>
git branch [NAME]
</code>

To change to another branch (don't forget to commit or reset your changes before changing to another branch, otherwise git will not be happy throwing away your work and overwriting it with other branch)

<code>
git checkout [NAME]
</code>

To delete a branch

<code>
git branch -D [NAME]
</code>

To add a file to the current branch

<code>
git add [filename.ext]
</code>

To delete a file from the current branch

<code>
git rm [filename.ext]
</code>
To commit your local changes to the current branch

<code>git commit -a -m "My commit message text"
</code>

To throw away the latest code changes you've done and get back to the last commited state

<code>
git reset --hard
</code>

Be aware that this is not a Git tutorial at all. To know how to use Git, consult the Git book at [[http://book.git-scm.com/|http://book.git-scm.com/]] or any other tutorials on the net.

===== Code formatting =====

\\
Please read the page on [[opencpn:developer_manual:developer_guide:code_formatting|Code Formatting]] before writing new code for OpenCPN.

===== Publishing your code =====

\\
The best way to ensure your code gets properly submitted to OpenCPN is to create a clone of the OpenCPN GitHub master repository, and push your commits to your cloned repository. When everything is available on Github you can either send a mail the developers or create an issue in [[http://opencpn.willkamp.com|http://opencpn.willkamp.com]] describing your work and referenceing the github commit URL.\\
\\
The official development master is here: [[https://github.com/OpenCPN/OpenCPN|https://github.com/OpenCPN/OpenCPN]]\\
===== Creating a patch =====

\\
Expecting your branch is checked out and you are in your working directory. Simply issue:

<code>
git diff master> mystuff.patch
</code>

\\
In the newly created file called //mystuff.patch// you may review the code you are going to submit with any text editor.
===== Submitting a patch =====

\\
Create a Flyspray account at [[http://opencpn.willkamp.com|http://opencpn.willkamp.com]]

==== Bugfix: ====

Attach the patch with comment to the corresponding issue in the bugtracker - for 4.5.x [[http://opencpn.willkamp.com/index.php?project=76&do=index&switch=1|http://opencpn.willkamp.com/index.php?project=76&do=index&switch=1]]

==== New feature: ====

Attach the patch with comment to the corresponding issue in the Feature requests tracker at [[http://opencpn.willkamp.com/index.php?do=newtask&project=6|http://opencpn.willkamp.com/index.php?do=newtask&project=6]]

